package com.gzbugu.polytechsasia.servlet;

import com.gzbugu.polytechsasia.factory.ServiceFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created with IntelliJ IDEA. User: Bokchoy Date: 11/1/12 Time: 3:23 PM
 */
public class DeleteArticle extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String ids = req.getParameter("ids");
		System.out.println(ids);
		resp.setContentType("text/html;charset=UTF-8");
		PrintWriter out = resp.getWriter();
		int result = ServiceFactory.getDeleteArticleService()
				.deleteArticleByIds(ids);
		out.print(result);
	}
}
